package com.hsl.study.controller;

import dev.langchain4j.model.chat.ChatLanguageModel;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Author: hsl
 * @CreateTime: 2025-03-12  11:15
 */
@Slf4j
@RestController
public class HelloLangChainController {

    @Resource
    private ChatLanguageModel chatLanguageModel;

// http://localhost:12332/langchain?prompt=如何学习阿里云
    @GetMapping("/langchain")
    public String hello(@RequestParam(value = "prompt",defaultValue = "你是谁") String prompt) {
        String response = chatLanguageModel.generate(prompt);
        log.info("response:{}", response);
        return response;
    }
}
